/**
 * 
 */
package niuke;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * @author zhongfang
 *
 */
public class 连续子串最大和 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		ArrayList<Integer> inputList=new ArrayList<>();
		while (scanner.hasNextInt()) {
			inputList.add(scanner.nextInt());
		}
		int maxSum=Integer.MIN_VALUE;
		int sum=0;
		for (Integer integer : inputList) {
			sum+=integer;
			maxSum=Math.max(maxSum, sum);
			if(sum<0){
				sum=0;
			}
		}
		System.out.println(maxSum);
	}
}
